package com.lch.mebatis.v1;

/**
 * @author: liuchenhui
 * @create: 2019-05-09 22:12
 **/
public class LchSqlSession {

    private LchConfiguration configuartion;// 配置类

    private LchExecutor executor;// 执行器

    public LchSqlSession(LchConfiguration configuartion, LchExecutor executor) {
        this.configuartion = configuartion;
        this.executor = executor;
    }

    /**
     * 调用Executor执行单条查询
     */
    public <T> T selectOne(String statmentId, Object paramer) {
        final String sql = LchConfiguration.sqlMappings.getString(statmentId);
        return executor.query(sql, paramer);
    }

    /**
     * 获取一个mapper代理对象
     */
    public <T> T getMapper(Class clazz) {
        return configuartion.getMapper(clazz, this);
    }
}
